package com.saudidentalapp;

import java.util.ArrayList;
import java.util.List;

import android.app.Activity;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.TextView;

import com.saudidentalapp.datamodels.ProgramMinutes;

public class MinutesAdapter extends ArrayAdapter<ProgramMinutes>
{

	Context context;
    int layoutResourceId;    
    ArrayList<ProgramMinutes>data;
	public MinutesAdapter(Context context, int resource, List<ProgramMinutes> objects) 
	{
		super(context, resource, objects);
		 this.layoutResourceId = resource;
	        this.context = context;
	        this.data = (ArrayList<ProgramMinutes>) objects;
	}
	
	@Override
	public View getView(int position, View convertView, ViewGroup parent) 
	{
		View row = convertView;
		ProgramHolder holder = null;
       
        if(row == null)
        {
            LayoutInflater inflater = ((Activity)context).getLayoutInflater();
            row = inflater.inflate(layoutResourceId, parent, false);
           
            holder = new ProgramHolder();
           // holder.txtDate = (TextView)row.findViewById(R.id.xtxtDates);
            holder.txtProgrameTitle = (TextView)row.findViewById(R.id.textView1);
            holder.txtTime = (Button)row.findViewById(R.id.button1);
           
            row.setTag(holder);
        }
        else
        {
            holder = (ProgramHolder)row.getTag();
        }
       
        ProgramMinutes program = getItem(position);
        //holder.txtDate.setText(program.getDate());
       // holder.txtDate.setOnClickListener(null);
        holder.txtProgrameTitle .setText(program.getDescription());
        holder.txtTime.setText(program.getStartTime() +" - " +program.getEndTime());
        return row;
    }
   
    static class ProgramHolder
    {       
        //TextView txtDate;
        TextView txtProgrameTitle;
        Button txtTime;
    }


}
